using System;
using System.Collections.Generic;
using System.Text;
using FlatRedBall;
using FlatRedBall.Input;
using FlatRedBall.AI.Pathfinding;
using FlatRedBall.Graphics.Animation;
using FlatRedBall.Graphics.Particle;

using FlatRedBall.Math.Geometry;
using FlatRedBall.Math.Splines;
using BitmapFont = FlatRedBall.Graphics.BitmapFont;
using Cursor = FlatRedBall.Gui.Cursor;
using GuiManager = FlatRedBall.Gui.GuiManager;

#if FRB_XNA || SILVERLIGHT
using Keys = Microsoft.Xna.Framework.Input.Keys;
using Vector3 = Microsoft.Xna.Framework.Vector3;
using Texture2D = Microsoft.Xna.Framework.Graphics.Texture2D;


#endif

namespace NereusGame.Entities
{

	public partial class Player
	{
        protected Camera mCamera;
        private const float CAMERA_BOUNDS = 2f;    // boundry for the Camera to move with the player

        protected void CustomInitialize()
		{
            HullTexture.Texture = FlatRedBallServices.Load<Texture2D>("/Resources/Textures/Ship.png");
            base.CustomInitialize();
            mCamera = SpriteManager.Camera;
		}

		private void CustomActivity()
		{
            moveShip();
            RotationByAcceleration();
            CameraMovement();
		}

		private void CustomDestroy()
		{


		}

        private static void CustomLoadStaticContent(string contentManagerName)
        {


        }

        protected void RotationByAcceleration()
        {
            if (Acceleration.Length() > 10f)
                Body.RelativeRotationZ = HullTexture.RelativeRotationZ = (float)(Math.Atan2(Acceleration.Y, Acceleration.X) - (Math.PI * .5f));
        }

        private void moveShip()
        {
            Acceleration.X = accel.CurrentValue.Acceleration.X * 300;
            Acceleration.Y = accel.CurrentValue.Acceleration.Y * 300;
        }

        protected virtual void CameraMovement()
        {
            mCamera.Acceleration = (Position - mCamera.Position) * (Position - mCamera.Position).Length() * CAMERA_BOUNDS;
            mCamera.Acceleration.Z = 0;
            mCamera.Drag = 10;
        }
	}
}
